//
//  VenueCell.m
//  oc1
//
//  Created by kokuma on 2017/2/11.
//  Copyright © 2017年 kokumams. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "VenueCell.h"
#import "UIColor+expanded.h"
#import "UIImageView+WebCache.h"
#import "VenueBean.h"

@interface VenueCell ()
@property (strong, nonatomic) UIImageView *userIconView;
@property (strong, nonatomic) UILabel *name;

@end

@implementation VenueCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        // Initialization code
        CGFloat screen = [UIScreen mainScreen].bounds.size.width;
        if (!_userIconView) {
            _userIconView = [[UIImageView alloc] initWithFrame:CGRectMake(5,5, screen-10, [VenueCell cellHeight]-20)];
            // [_userIconView doCircleFrame];
            [self.contentView addSubview:_userIconView];
        }
        if (!_name) {
            _name = [UILabel alloc];
            //_name.frame = CGRectMake(_name.frame.origin.x,_name.frame.origin.y, 150, 25);
            [_name initWithFrame:CGRectMake(_name.frame.origin.x,_name.frame.origin.y, 250, 25)];
            _name.font = [UIFont systemFontOfSize:18];
            _name.textColor = [UIColor whiteColor];
            // _name.backgroundColor = [UIColor clearColor];
            [self.contentView addSubview:_name];
        }
        _name.center = self.center;
    }
    return self;
}

- (void)layoutHeight{
    _name.center = self.center;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    NSString *str = @"http://mbpcos.image.alimmdn.com/avatar/D6B77C75-42B1-4AB6-9A99-2FD06381CC11@50w";
    if (_bean) {
        id pics = _bean.images;
        if(pics){
            for(id pic in pics){
                if(pic){
                    //VenueBean *bean = [[VenueBean alloc]initWithDictionary:pic];
                    str = pic ;
                    break;
                }
            }
        }
    }
    str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *url = [NSURL URLWithString:str];
    //[_userIconView sd_setImageWithURL:url];
    [_userIconView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"a"]];
    
    _name.text = @"kokuma";
    if(_bean&&_bean.name){
        _name.text = _bean.name;
    }
    
    //[self.contentView addBadgeTip:badgeTip withCenterPosition:CGPointMake(300-25, CGRectGetMaxY(_time.frame) +10)];
}

+ (CGFloat)cellHeight{
    return 200.0;
}

@end
